<?php
$this->headTitle('Dự án','append');
?>
<div class="dashboard-menu dashboard-admin">
    <span class="back">&nbsp;</span>
    <a href="/admin/user"><h1>Dự án</h1></a>
    <span class="text">Thêm</span>
</div>
<div class="row placeholders">
    <div class="col-md-12">
        <div class="widget-big">
            <div class="search-result text-left">
                <?php
                    if(isset($this->mess)){
                        if($this->flag == 'success')
                            echo '<div class="bg-success">',$this->mess,'</div>';
                        elseif($this->flag == 'alert')
                            echo '<div class="bg-warning">',$this->mess,'</div>';
                        else
                            echo '<div class="bg-danger">',$this->mess,'</div>';
                    }
                    echo $this->form; 
                ?>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">	
$(document).ready(function(){
    $('select#districtId  option[value!="0"]').remove();
    $('select#districtId').append(new Option('--- Quận/Huyện ---',0));
    $('select#provinceId').change(function(){
        var proId=$(this).val();                                                           
        $.ajax({
            type: "POST",
            url: "/admin/location/getdistrict/province/"+proId,                                                                    
            dataType: 'json',                         
            success: function(data) {
                //alert(JSON.stringify(data));                    
                $('select#districtId  option[value!="0"]').remove();                                                            
                for(var key in data)
                {                        
                    $('select#districtId').append(new Option(data[key],key));
                }                                                      
            },
            error: function() {
                alert('failed');
                $('select#districtId option[value!="0"]').remove();
            }
        });
        return false;                       
    });
});
</script>
<?php     
    if($this->form->districtId->getValue()){        
?>
    <script type="text/javascript">	
        $(document).ready(function(){       
            var proId=$('select#provinceId').val();                                                           
            $.ajax({
                type: "POST",
                url: "/admin/location/getdistrict/province/"+proId,                                                                    
                dataType: 'json',                         
                success: function(data) {
                    //alert(JSON.stringify(data));                    
                    $('select#districtId  option[value!="0"]').remove();                                                            
                    for(var key in data)
                    {                        
                        $('select#districtId').append(new Option(data[key],key));
                    }    
                    $('select#districtId').val('<?php echo $this->form->districtId->getValue()?>');                                                                                        
                },
                error: function() {
                    alert('failed');
                    $('select#districtId option[value!="0"]').remove();
                }
            });        
        });
    </script>    
<?php }
?>

